home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s1.arc / HANDLEKB.MOD < prev    next >
Text File  |  1987-05-16  |  5KB  |  122 lines

  1. (*----------------------------------------------------------------------*)
  2. (*     Handle_Keyboard_Input ---  Read keyboard input in terminal mode  *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Handle_Keyboard_Input( VAR Done                  : BOOLEAN;
  6.                                  VAR Reset_Requested       : BOOLEAN;
  7.                                  VAR ClearScreen_Requested : BOOLEAN );
  8.  
  9. (*----------------------------------------------------------------------*)
  10. (*                                                                      *)
  11. (*     Procedure:  Handle_Keyboard_Input                                *)
  12. (*                                                                      *)
  13. (*     Purpose:    Reads keyboard input in terminal modes               *)
  14. (*                                                                      *)
  15. (*     Calling Sequence:                                                *)
  16. (*                                                                      *)
  17. (*        Handle_Keyboard_Input                                         *)
  18. (*                                                                      *)
  19. (*----------------------------------------------------------------------*)
  20.  
  21. VAR
  22.    Ch               : CHAR;
  23.    Save_Screen_Line : INTEGER;
  24.  
  25. BEGIN (* Handle_Keyboard_Input *)
  26.                                    (* Read input character *)
  27.    READ( Kbd , Ch );
  28.                                    (* Assume not reset     *)
  29.    Reset_Requested := FALSE;
  30.                                    (* Assume not clear screen *)
  31.    ClearScreen_Requested := FALSE;
  32.                                    (* Process it           *)
  33.    IF ( Ch = CHR( ESC ) ) THEN
  34.       IF KeyPressed THEN
  35.          BEGIN  (* Escape AND KeyPressed *)
  36.  
  37.                                    (* Get character following escape *)
  38.             READ( Kbd , Ch );
  39.  
  40.             IF ( Ch = CHR( SI ) ) THEN
  41.                Reset_Requested := TRUE
  42.             ELSE
  43.                BEGIN  (* Not terminal reset *)
  44.  
  45.                   Save_Screen_Line := Max_Screen_Line;
  46.  
  47.                   Process_Command( Ch, TRUE, PibTerm_Command );
  48.  
  49.                   CASE PibTerm_Command OF
  50.                      Null_Command: ;
  51.                      ClearSy     : ClearScreen_Requested := TRUE;
  52.                      ELSE
  53.                                    Execute_Command( PibTerm_Command, Done, FALSE );
  54.                   END (* CASE *);
  55.  
  56.                   Reset_Requested := ( Max_Screen_Line <> Save_Screen_Line );
  57.  
  58.                END   (* Not terminal reset *);
  59.  
  60.             EXIT;
  61.  
  62.          END  (* Escape AND KeyPressed *)
  63.       ELSE  (* Escape only *)
  64.          IF Async_XOff_Received THEN
  65.             BEGIN
  66.                Async_XOff_Received := FALSE;
  67.                IF Do_Status_Line THEN
  68.                   Write_To_Status_Line( '             ', 65 );
  69.                EXIT;
  70.             END;
  71.                                    (* Handle other characters *)
  72.    CASE ORD( Ch ) OF
  73.  
  74.       BS:   Ch := BS_Char;
  75.  
  76.       DEL:  Ch := Ctrl_BS_Char;
  77.  
  78.       ELSE  IF Send_Upper_Case_Only THEN
  79.                Ch := UpCase( Ch );
  80.  
  81.    END (* CASE *);
  82.                                    (* Put char in received buffer if *)
  83.                                    (* local echo on so we display it *)
  84.                                    (* later on.                      *)
  85.  
  86.    IF Local_Echo THEN Async_Stuff( Ch );
  87.  
  88.                                    (* Learn this character if doing a *)
  89.                                    (* learn script.                   *)
  90.    IF Script_Learn_Mode THEN
  91.       Learn_A_Character( Ch );
  92.                                    (* Send this character to remote.  *)
  93.    Async_Send( Ch );
  94.                                    (* If Ch = CR and New_Line mode, send  *)
  95.                                    (* a LF as well.                       *)
  96.    IF ( Ch = CHR( CR ) ) THEN
  97.       IF New_Line THEN
  98.          Async_Send( CHR( LF ) );
  99.  
  100.                                    (* Stuff character into keyboard line, *)
  101.                                    (* except backspaces/deletes           *)
  102.  
  103.    CASE ORD( Ch ) OF
  104.       DEL,
  105.       BS    : IF ( Keyboard_Line_Pos > 0 ) THEN
  106.                  Keyboard_Line_Pos := PRED( Keyboard_Line_Pos );
  107.       ELSE
  108.               IF ( Keyboard_Line_Pos = 255 ) THEN
  109.                  MOVE( Keyboard_Line[2], Keyboard_Line[1], 254 )
  110.               ELSE
  111.                  Keyboard_Line_Pos := SUCC( Keyboard_Line_Pos );
  112.  
  113.               Keyboard_Line[Keyboard_Line_Pos] := Ch;
  114.               Keyboard_Line[0]                 := CHR( Keyboard_Line_Pos );
  115.  
  116.               IF ( Ch = CHR( CR ) ) THEN
  117.                  Keyboard_Line_Pos := 0;
  118.  
  119.    END (* CASE *);
  120.  
  121. END   (* Handle_Keyboard_Input *);
  122.